package com.dhsc.service.impl.khzne;

import com.dhsc.domain.ywzx.khzne.KhzzqjxxVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.domain.yypt.ResponseObject;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.ywzj.khzne.IYwKhzzqjxxDao;
import com.dhsc.service.khzne.IYwKhzzqjxxService;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 客户资质全景信息
 * @date 2024/10/31 10:34
 */
@Slf4j
@Service
public class YwKhzzqjxxServiceImpl implements IYwKhzzqjxxService {

    @Autowired
    private IYwKhzzqjxxDao ywKhzzqjxxDao;
    @Override
    public LayuiTableVo queryKhzzqjxxinfo(KhzzqjxxVo k) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            PageMethod.startPage(k.getPage(), k.getLimit());
            List<KhzzqjxxVo> list = ywKhzzqjxxDao.queryKhzzqjxxinfo(k);
            PageInfo<KhzzqjxxVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setMsg("");
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
        }catch (Exception e){
            log.error("查询客户资质全景信息出错",e);
            throw new MyException("查询客户资质全景信息出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject queryZhzd(KhzzqjxxVo k) {
        ResponseObject obj = new ResponseObject();
        try {
            List<KhzzqjxxVo> list = ywKhzzqjxxDao.queryZhzd(k);
            obj.setStatus(200);
            obj.setData(list);
        }catch (Exception e){
            log.error("查询zh.txtdm字典出错",e);
            throw new MyException("查询zh.txtdm字典出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject queryQszd(KhzzqjxxVo k) {
        ResponseObject obj = new ResponseObject();
        try {
            List<KhzzqjxxVo> list = ywKhzzqjxxDao.queryQszd(k);
            obj.setStatus(200);
            obj.setData(list);
        }catch (Exception e){
            log.error("查询qs.txtdm字典出错",e);
            throw new MyException("查询qs.txtdm字典出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject queryYwzxZDYyb(KhzzqjxxVo k) {
        ResponseObject obj = new ResponseObject();
        try {
            List<KhzzqjxxVo> list = ywKhzzqjxxDao.queryYwzxZDYyb(k);
            obj.setStatus(200);
            obj.setData(list);
        }catch (Exception e){
            log.error("查询营业部信息出错",e);
            throw new MyException("查询营业部信息出错",e);
        }
        return obj;
    }
}
